<template>
  <!--视图-->
  <div >
    <el-container>
      <el-header>
        <h1>农产品</h1>
      </el-header>
      <el-container>
        <el-aside width="200px">
          <el-menu
              default-active="2"
              class="el-menu-vertical-demo"
              background-color="#545c64"
              text-color="#fff"
              active-text-color="#ffd04b"
          router>
            <el-submenu :index="a.id" v-for="a in menus" :key="a.id">
              <template slot="title">
                <i class="el-icon-location"></i>
                  <span>{{a.name}}</span>
              </template>
              <el-menu-item-group >
                <el-menu-item   v-for=" b in a.children"  :index="b.path" :key="b.id" >{{b.name}}</el-menu-item>
              </el-menu-item-group>
            </el-submenu>
          </el-menu>
        </el-aside>
        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>


  </div>
</template>

<script>
export default {
  name: "TreeView",
  data() {//属性
    return {
      menus:[]
    }
  }, methods: {//自定义方法
     list()
     {
       this.axios.post("/system/system/list").then(res=>{
         this.menus=res.data.data
       })
     }
  }, created() { //钩子函数
   this.list();
  }
}
</script>

<style>
.el-header, .el-footer {
  background-color: #42b983;
  color: #E9EEF3;
  text-align: center;
  line-height: 30px;
}

.el-aside {
  background-color: #D3DCE6;
  color: #333;
  text-align: center;
  line-height: 160px;
}

.el-main {
  background-color: #E9EEF3;
  color: #333;
  text-align: center;
  line-height: 50px;
}

body > .el-container {
  margin-bottom: 190px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}
</style>